# To change this template, choose Tools | Templates
# and open the template in the editor.

__author__ = "kiira"
__date__ = "$May 20, 2011 5:52:30 PM$"

import pygame
from Util import Enum

#Game's attack types
ATK_TYPE = Enum( [ "MISSILE", "MELEE"] )
#Game's attack elements
ELEMENT = Enum( [ "NEUTRAL", "WATER", "EARTH", "FIRE", "WIND", "POISON", "HOLY", "SHADOW", "GHOST", "UNDEAD" ] )
#Game's races
RACES = Enum ( ["DEMIHUMAN", "BRUTE", "INSECT", "FISH", "DRAGON", "PLANT", "FORMLESS", "ANGEL", "DEMON", "UNDEAD" ] )
#Game's entity sizes
SIZE = Enum( [ "SMALL", "MEDIUM", "LARGE" ] )

class Stats:
	''' Defines an entity primary stats and have methods to calculate secundary stats.'''
	def __init__( self, **kwargs ):
		'''
		Initializes a Stat object.
		
		Kwargs Argument Keywords:
		lvl -- Level of the entity.
		stre -- Strength of the entity.
		agi -- Agility of the entity.
		int -- Inteligence of the entity.
		dex -- Dexterity of the entity.
		vit -- Vitality of the entity.
		luk -- Luck of the entity.
		'''
		self.lvl = kwargs.get( 'lvl', 0 )
		self.stre = kwargs.get( 'stre', 0 )
		self.agi = kwargs.get( 'agi', 0 )
		self.int = kwargs.get( 'int', 0 )
		self.dex = kwargs.get( 'dex', 0 )
		self.vit = kwargs.get( 'vit', 0 )
		self.luk = kwargs.get( 'luk', 0 )
	
	def base_atk( self, weapon_type ):
		''' Calculates the base attack of an entity using this stats and a given weapon type.'''
		if weapon_type == ATK_TYPE.MELEE:
			return self.stre + ( self.stre / 10 ) ** 2 + self.dex / 5 + self.luk / 5 
		elif weapon_type == ATK_TYPE.MISSILE:
			return self.dex + ( self.dex / 10 ) ** 2 + self.stre / 5 + self.luk / 5 
		else:
			return 0
	
	def base_matk_range( self ):
		''' Calculates and returns the magic attack range (min value and max value) for this stats. '''
		return ( self.int + ( self.int / 7 ) ** 2 , self.int + ( self.int / 5 ) ** 2 )
	
	def soft_def( self ):
		''' Returns the soft defence for this stats. '''
		return self.vit
	
	def soft_mdef( self ):
		''' Returns the soft magic defence for this stats. '''
		return self.int
	
	def hit( self ):
		''' Calculates and returns the hit value for this stats. '''
		return self.lvl + self.dex
	
	def flee( self ):
		''' Calculates and returns the flee value for this stats. '''
		return self.lvl + self.agi
	
	def critical( self ):
		''' Calculates and returns the critical ratio for this stats. '''
		return 1 + 0.3 * self.luk 
	
	def perfect_dodge( self ):
		''' Calculates and returns the perfect dodge ratio for this stats. '''
		return 1 + self.luk / 10
	
class Classification:
	''' Defines an entity classification, given it's size, race and element. '''
	def __init__( self, race, size, element ):
		'''
		Initializes the classification.
		
		Argument Keywords:
		race -- Entity race.
		size -- Entity size.
		element -- Entity element.
		'''
		self.race = race
		self.size = size
		self.element = element					  
			
class Entity:
	''' Defines any entity of the game, monster or character. '''
	
	#entity types enumeration
	ENTITY_TYPES = Enum( ['char', 'monster'] )
	
	def __init__( self, classification, stats, sprite ):
		'''
		Initializes an entity with a classification, it's stats and a sprite for graphical representation. 
		
		Argument keywords:
		classification -- Entity classification.
		stats -- Entity stats.
		sprite -- Entity sprite.
		'''
		self.classification = classification
		self.stats = stats
		self.sprite = sprite

class Char( Entity ):
	''' Defines a character entity. '''
		
	#char classes enumeration
	CHAR_CLASSES = Enum( ['novice', 'hunter'] )
	#char genres enumeration
	CHAR_GENRES = Enum( ['male', 'female'] )
						
if __name__ == '__main__':
	stats = Stats()
	
	pygame.init()
	#acciones1 = SpriteAnimation( "novice_male", "char" )
	#acciones2 = ActionsAnimations( "novice_male", "char" )
	#acciones3 = ActionsAnimations( "novice_female", "char" )
	#acciones4 = ActionsAnimations( "novice_female", "char" )

	
	pantalla = pygame.display.set_mode( ( 1200, 300 ) )
	clock = pygame.time.Clock()
	
	while True:
		pantalla.fill( ( 255, 255, 255 ) )
		#acciones1.render( pantalla, [0, 0] )
		#acciones2.render( pantalla, [600,0] )
		#acciones3.render( pantalla, [0, 150] )
		#acciones4.render( pantalla, [600, 150] )
		pygame.display.flip()
		
		for event in pygame.event.get():
			if event.type == pygame.locals.QUIT:
				pygame.quit()

		clock.tick( 35 )
		
	print stats.base_atk( ATK_TYPE.MELEE )
	print stats.base_atk( ATK_TYPE.MISSILE )
	print stats.base_matk_range()
	print stats.soft_def()
	print stats.soft_mdef()
	print stats.hit()
	print stats.flee()
	print stats.critical()
	print stats.perfect_dodge()
